package cn.iocoder.yudao.module.indicator.service.element;

import cn.iocoder.yudao.module.indicator.dao.element.ElementRoomDayDao;
import cn.iocoder.yudao.module.indicator.domain.dto.IndexCalculationDto;
import cn.iocoder.yudao.module.indicator.domain.vo.ElementCalculationVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ElementRoomServiceImpl implements ElementCalculationService{
    @Resource
    ElementRoomDayDao elementRoomDayDao;

    private Boolean checkDateType(IndexCalculationDto indexCalculationDto){
        String DATE_TYPE = "日,月,年";
        return DATE_TYPE.contains(indexCalculationDto.getDateType());
    }

    @Override
    public List<ElementCalculationVo> getElementById(IndexCalculationDto indexCalculationDto) {
        if(checkDateType(indexCalculationDto)){
            return elementRoomDayDao.getElementByDate(indexCalculationDto);
        }
        return new ArrayList<ElementCalculationVo>();
    }

    @Override
    public List<ElementCalculationVo> getElementGroupInstitute(IndexCalculationDto indexCalculationDto) {
        if(checkDateType(indexCalculationDto)){
            return elementRoomDayDao.getElementGroupInstitute(indexCalculationDto);
        }
        return new ArrayList<ElementCalculationVo>();
    }

    @Override
    public List<ElementCalculationVo> getElementGroupDoctor(IndexCalculationDto indexCalculationDto) {
        if(checkDateType(indexCalculationDto)){
            return elementRoomDayDao.getElementGroupDoctor(indexCalculationDto);
        }
        return new ArrayList<ElementCalculationVo>();
    }

    @Override
    public List<ElementCalculationVo> getElementGroupRoom(IndexCalculationDto indexCalculationDto) {
        if(checkDateType(indexCalculationDto)){
            return elementRoomDayDao.getElementGroupRoom(indexCalculationDto);
        }
        return new ArrayList<ElementCalculationVo>();
    }

    @Override
    public List<ElementCalculationVo> getElementTrend(IndexCalculationDto indexCalculationDto) {
        if(checkDateType(indexCalculationDto)){
            return elementRoomDayDao.getElementHistoricalData(indexCalculationDto);
        }
        return new ArrayList<ElementCalculationVo>();
    }
}

